﻿using System;
using System.Configuration;
using System.Web.Mvc;
using System.Web.Security;
using Innovacall.MyPrettyCMS.PlugIns.PI_ContactManager_CommonLayer;
using Innovacall.MyPrettyCMS.PlugIns.PI_ContactManager_DataLayer;
using Innovacall.MyPrettyCMS.PlugIns.PI_ContactManager_DomainLayer;
using Innovacall.MyPrettyCMS.PlugIns.PI_ContactManager_ResourcesLayer;
using Innovacall.MyPrettyCMS.PlugIns.PI_ContactManager_ResourcesLayer.Properties;
using INNOVACALL.Framework.Common;
using INNOVACALL.Framework.Common.Models;
using INNOVACALL.Framework.Common.MVCHelpers;
using MPC_PI_ContactManager.Controllers.ViewControllers;
using MPC_PI_ContactManager.Models.ViewModels;
using MPC_PI_ContactManager.Models.ViewModels.LayoutViewModels;

namespace MPC_PI_ContactManager.Controllers.ViewControllers.LayoutViewControllers
{
    public class HomeController : _LayoutViewControllers_Base<Home_ViewModel>
    {
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.eMethodBase = "InnovaApp.Portals.InnovaAppFrontOfficePortal.Controllers.HomeController";
            base.specificCssCollection = new string[] { "_FormCommon.css", "Views/Home.css" };
            base.specificJSCollection = null;
            base.dynamicJSCollection = new string[] { "/ScriptsG/inoHomeDynamic.js" };
            base.specificJqueryJSCollection = new string[] { "Views/Home.js" };
            base.externalCSS = null;
            base.Initialize(requestContext);
        }

        /// <summary>
        /// Affichage du contenu de la page d'accueil
        /// </summary>
        /// <returns></returns>
        [HttpGet, CacheManager(enCacheMode.NoCache)]
        public ActionResult Index()
        {
            string language = ConfigurationManager.AppSettings["DefaultLanguage"];

            //ViewBag.Message = "Modify this template to kick-start your ASP.NET MVC application.";
            using (DataRepositories _dataContext = new DataRepositories())
            {
                base.InitView(
                    pageTitle: Resources.View_Home_PageTitle,
                    openingMessage: string.Empty,
                    specificCssCollection: specificCssCollection,
                    specificJSCollection: specificJSCollection,
                    dynamicJSCollection: dynamicJSCollection,
                    specificJqueryJSCollection: specificJqueryJSCollection,
                    jsVariables: jsVariables,
                    externalCss: externalCSS,
                    metaToAdd: Meta,
                    _dataContext: _dataContext,
                    displayMenus: true,
                    language: language,
                    adminMode: false,
                    currentUser: Membership.GetUser(),
                    usesKendoUI:false,
                    jQueryUITheme: ConfigurationManager.AppSettings["JQueryUITheme"],
                    kendoUITheme: ConfigurationManager.AppSettings["KendoUITheme"]                    
                    );
            }
            
            return View(ContentData);
        }


        [HttpPost, Authorize(Roles = "Admin"), ValidateInput(false)]
        protected JsonResult SaveContent(int id, object model)
        {
            Guid LastModifierId = (Guid)(Membership.GetUser().ProviderUserKey);
            string eMethod = eMethodBase + "Save[POST]";
            //object eParameters = new { model = model };
            JsonResult toReturn = new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet };
            return toReturn;
        }

    }
}
